package cz.fimuni.pa165.backendderby.services;

import cz.fimuni.pa165.backendderby.dao.CompanyDAO;
import cz.fimuni.pa165.backendderby.entities.Company;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Lukáš Slovák
 */
@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private CompanyDAO companyDAO;

    public void setCompanyDAO(CompanyDAO companyDAO) {
        this.companyDAO = companyDAO;
    }

    @Transactional
    public void createCompany(Company company) {

        companyDAO.create(company);

    }

    @Transactional
    public void removeCompany(Company company) {

        companyDAO.remove(company);

    }

    @Transactional
    public boolean updateCompany(Company company) {

        return companyDAO.update(company);

    }

    @Transactional
    public Company findCompany(Long id) {

        return companyDAO.find(id);

    }

    @Transactional
    public List<Company> findAllCompanies() {

        return companyDAO.findAll();

    }
}